//
//  UIBarButtonItem+Extensions.swift
//  微博
//
//  Created by LH on 2017/5/25.
//  Copyright © 2017年 LH. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    ///遍历构造函数
    convenience init(title:String,fontSize:CGFloat = 16,target:AnyObject?,action:Selector,isBack:Bool = false) {
        let but : UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.white, highlightedColor: UIColor.orange)
       
        if isBack{
            let imageName = "navigationbar_back_withtext"
            but.setImage(UIImage.init(named: imageName), for: UIControlState.normal)
            but.setImage(UIImage.init(named: imageName + "_highlighted"), for: UIControlState.highlighted)
            but.sizeToFit()
        }
        
        but.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        self.init(customView: but)
    }
}
